﻿namespace Hanoi
{
    internal class Program
    {
        /// <summary>
        /// Hanoi
        /// </summary>
        /// <param name="args"></param>
        public static void Hanoi(int n,char A,char B,char C)
        {
            if (n == 1) 
                Console.WriteLine($"将第{n}个盘从{A}移到{C}");
            else
            {
                //将A座上的n-1个盘借助C座移到B座
                Hanoi(n - 1, A, C, B);
                //将A座上最后一个盘移到C座
                Console.WriteLine($"将第{n}个盘从{A}移到{C}");
                //将B座上n-1个盘借助A座移到C座
                Hanoi(n - 1, B, A, C);
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("请输入塔数：");
            int number = int.Parse(Console.ReadLine());
            Hanoi(number,'A','B','C');        
        }
    }
}